@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIF42C880
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import io.dcloud.uniapp.extapi.chooseImage as uni_chooseImage
import io.dcloud.uniapp.extapi.getStorage as uni_getStorage
import io.dcloud.uniapp.extapi.hideLoading as uni_hideLoading
import io.dcloud.uniapp.extapi.navigateTo as uni_navigateTo
import io.dcloud.uniapp.extapi.showActionSheet as uni_showActionSheet
import io.dcloud.uniapp.extapi.showLoading as uni_showLoading
import io.dcloud.uniapp.extapi.showToast as uni_showToast
open class GenPagesIndexIndex : BasePage {
    constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
        onLoad(fun(_: OnLoadOptions) {
            this.sortImages("week")
        }
        , __ins)
        onPageShow(fun() {
            this.sortImages(this.activeTimeFilter)
        }
        , __ins)
    }
    @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
    override fun `$render`(): Any? {
        val _ctx = this
        val _cache = this.`$`.renderCache
        return createElementVNode("view", utsMapOf("class" to "container"), utsArrayOf(
            if (isTrue(_ctx.recentImages)) {
                createElementVNode("view", utsMapOf("key" to 0, "class" to "recent-section"), utsArrayOf(
                    createElementVNode("view", utsMapOf("class" to "section-header"), utsArrayOf(
                        createElementVNode("view", utsMapOf("class" to "section-title"), utsArrayOf(
                            createElementVNode("text", utsMapOf("style" to normalizeStyle(utsMapOf("font-size" to "20px")), "onClick" to _ctx.showAddOptions), "画廊", 12, utsArrayOf(
                                "onClick"
                            )),
                            createElementVNode("button", utsMapOf("class" to "add-btn", "onClick" to _ctx.showAddOptions), "+", 8, utsArrayOf(
                                "onClick"
                            ))
                        )),
                        createElementVNode("view", utsMapOf("class" to "button-group"), utsArrayOf(
                            createElementVNode("button", utsMapOf("class" to normalizeClass(utsArrayOf(
                                "filter-btn",
                                utsMapOf("active" to (_ctx.activeTimeFilter === "week"))
                            )), "onClick" to fun(){
                                _ctx.sortImages("week")
                            }), "周", 10, utsArrayOf(
                                "onClick"
                            )),
                            createElementVNode("button", utsMapOf("class" to normalizeClass(utsArrayOf(
                                "filter-btn",
                                utsMapOf("active" to (_ctx.activeTimeFilter === "month"))
                            )), "onClick" to fun(){
                                _ctx.sortImages("month")
                            }), "月", 10, utsArrayOf(
                                "onClick"
                            )),
                            createElementVNode("button", utsMapOf("class" to normalizeClass(utsArrayOf(
                                "filter-btn",
                                utsMapOf("active" to (_ctx.activeTimeFilter === "year"))
                            )), "onClick" to fun(){
                                _ctx.sortImages("year")
                            }), "年", 10, utsArrayOf(
                                "onClick"
                            ))
                        ))
                    ))
                ))
            } else {
                createElementVNode("view", utsMapOf("key" to 1, "class" to "empty-state"), utsArrayOf(
                    createElementVNode("text", utsMapOf("class" to "empty-text"), "还没有生成记录，点击拍照开始创作"),
                    createElementVNode("button", utsMapOf("class" to "start-btn", "onClick" to fun(){
                        _ctx.showAddOptions()
                    }
                    ), "开始拍照", 8, utsArrayOf(
                        "onClick"
                    ))
                ))
            }
            ,
            createElementVNode("view", utsMapOf("class" to "footer"), utsArrayOf(
                createElementVNode("text", utsMapOf("class" to "footer-text"), "基于ComfyUI的移动端AI图像生成应用")
            ))
        ))
    }
    open var recentImages: UTSJSONObject by `$data`
    open var activeTimeFilter: String by `$data`
    open var imageList: UTSArray<ResultImage> by `$data`
    @Suppress("USELESS_CAST")
    override fun data(): Map<String, Any?> {
        return utsMapOf("recentImages" to UTSJSONObject(), "activeTimeFilter" to "week", "imageList" to utsArrayOf<ResultImage>())
    }
    open var loadRecentImages = ::gen_loadRecentImages_fn
    open fun gen_loadRecentImages_fn() {
        uni_getStorage(GetStorageOptions(key = "imageList", success = fun(res){}))
        console.log("文件列表：", imageList)
        this.imageList = utsArrayOf(
            ResultImage(imageID = "0001", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-11 14:30", children = utsArrayOf(
                childImage(imageID = "0002", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-11 15:30", styleArray = utsArrayOf(
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                ), seed = "12345", sourceImagePath = "/static/sampleimage.jpg"),
                childImage(imageID = "0003", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-11 16:30", styleArray = utsArrayOf(
                    1,
                    1,
                    1,
                    1,
                    1,
                    1
                ), seed = "22222", sourceImagePath = "/static/sampleimage.jpg")
            )),
            ResultImage(imageID = "0004", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-10 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0005", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-9 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0006", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-4 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0007", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-3 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0008", imagePath = "/static/sampleimage.jpg", dateTime = "2025-6-2 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0009", imagePath = "/static/sampleimage.jpg", dateTime = "2025-5-30 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0010", imagePath = "/static/sampleimage.jpg", dateTime = "2025-5-29 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0011", imagePath = "/static/sampleimage.jpg", dateTime = "2025-5-28 14:30", children = utsArrayOf()),
            ResultImage(imageID = "0012", imagePath = "/static/sampleimage.jpg", dateTime = "2024-5-28 13:30", children = utsArrayOf()),
            ResultImage(imageID = "0013", imagePath = "/static/sampleimage.jpg", dateTime = "2024-5-28 12:30", children = utsArrayOf()),
            ResultImage(imageID = "0014", imagePath = "/static/sampleimage.jpg", dateTime = "2024-5-28 11:30", children = utsArrayOf())
        )
    }
    open var navigateTo = ::gen_navigateTo_fn
    open fun gen_navigateTo_fn(url: String) {
        uni_navigateTo(NavigateToOptions(url = url))
    }
    open var sortImages = ::gen_sortImages_fn
    open fun gen_sortImages_fn(timeRange: String) {}
    open var viewImage = ::gen_viewImage_fn
    open fun gen_viewImage_fn(item: ResultImage) {
        val imageID = item.imageID
        uni_navigateTo(NavigateToOptions(url = "/pages/result/result?item=" + imageID))
    }
    open var showAddOptions = ::gen_showAddOptions_fn
    open fun gen_showAddOptions_fn() {
        uni_showActionSheet(ShowActionSheetOptions(itemList = utsArrayOf(
            "拍照",
            "从相册选择"
        ), success = fun(res){
            if (res.tapIndex === 0) {
                uni_showLoading(ShowLoadingOptions(title = "打开相机..."))
                uni_chooseImage(ChooseImageOptions(count = 1, sourceType = utsArrayOf(
                    "camera"
                ), success = fun(res){
                    uni_hideLoading()
                    val item: UTSJSONObject = object : UTSJSONObject() {
                        var image = object : UTSJSONObject() {
                            var imageID = "0xbeddad69"
                            var imagePath = res.tempFilePaths[0]
                            var dateTime = "2025-6-16 9:17"
                            var sourceImagePath = null
                            var children = utsArrayOf<childImage>()
                        }
                        var index: Number = 0
                    }
                    uni_navigateTo(NavigateToOptions(url = "/pages/edit/edit?image=" + JSON.stringify(item)))
                }, fail = fun(err){
                    uni_hideLoading()
                    uni_showToast(ShowToastOptions(title = "拍照失败", icon = "none"))
                    console.error("Camera error:", err)
                }))
            } else if (res.tapIndex === 1) {
                this.chooseFromAlbum()
            }
        }
        ))
    }
    open var chooseFromAlbum = ::gen_chooseFromAlbum_fn
    open fun gen_chooseFromAlbum_fn() {
        uni_chooseImage(ChooseImageOptions(count = 1, sourceType = utsArrayOf(
            "album"
        ), success = fun(res){
            val item: UTSJSONObject = object : UTSJSONObject() {
                var image = object : UTSJSONObject() {
                    var imageID = "0xbeddad69"
                    var imagePath = res.tempFilePaths[0]
                    var dateTime = "2025-6-16 9:17"
                    var sourceImagePath = null
                    var children = utsArrayOf<childImage>()
                }
                var index: Number = 0
            }
            uni_navigateTo(NavigateToOptions(url = "/pages/edit/edit?image=" + JSON.stringify(item)))
        }
        , fail = fun(_){
            uni_showToast(ShowToastOptions(title = "选择图片失败", icon = "none"))
        }
        ))
    }
    companion object {
        val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
            normalizeCssStyles(utsArrayOf(
                styles0
            ), utsArrayOf(
                GenApp.styles
            ))
        }
        val styles0: Map<String, Map<String, Map<String, Any>>>
            get() {
                return utsMapOf("container" to padStyleMapOf(utsMapOf("backgroundColor" to "#f5f5f5", "height" to "100%", "display" to "flex", "flexDirection" to "column", "paddingTop" to 20, "paddingRight" to 20, "paddingBottom" to 20, "paddingLeft" to 20, "boxSizing" to "border-box")), "header" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "row", "alignItems" to "center", "marginBottom" to 30)), "logo" to padStyleMapOf(utsMapOf("width" to 40, "height" to 40, "marginRight" to 10)), "app-title" to padStyleMapOf(utsMapOf("fontSize" to 24, "fontWeight" to "bold", "color" to "#333333")), "card-container" to padStyleMapOf(utsMapOf("marginBottom" to 30)), "feature-card" to padStyleMapOf(utsMapOf("backgroundColor" to "#ffffff", "borderTopLeftRadius" to 15, "borderTopRightRadius" to 15, "borderBottomRightRadius" to 15, "borderBottomLeftRadius" to 15, "paddingTop" to 20, "paddingRight" to 20, "paddingBottom" to 20, "paddingLeft" to 20, "marginBottom" to 15, "display" to "flex", "flexDirection" to "row", "alignItems" to "center", "boxShadow" to "0 2px 10px rgba(0, 0, 0, 0.05)")), "card-icon" to padStyleMapOf(utsMapOf("width" to 50, "height" to 50, "borderTopLeftRadius" to 25, "borderTopRightRadius" to 25, "borderBottomRightRadius" to 25, "borderBottomLeftRadius" to 25, "display" to "flex", "alignItems" to "center", "justifyContent" to "center", "fontSize" to 24, "marginRight" to 15)), "camera-icon" to padStyleMapOf(utsMapOf("backgroundColor" to "#E1F5FE")), "settings-icon" to padStyleMapOf(utsMapOf("backgroundColor" to "#FFF3E0")), "card-content" to padStyleMapOf(utsMapOf("flex" to 1)), "card-title" to padStyleMapOf(utsMapOf("fontSize" to 18, "fontWeight" to "bold", "color" to "#333333", "marginBottom" to 5)), "card-desc" to padStyleMapOf(utsMapOf("fontSize" to 14, "color" to "#666666")), "card-arrow" to padStyleMapOf(utsMapOf("fontSize" to 20, "color" to "#999999")), "recent-section" to padStyleMapOf(utsMapOf("flex" to 1, "display" to "flex", "flexDirection" to "column", "overflow" to "hidden")), "section-header" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "row", "justifyContent" to "space-between", "alignItems" to "center", "marginBottom" to 15, "flexShrink" to 0)), "section-title" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "row", "alignItems" to "center", "fontWeight" to "bold", "color" to "#333333")), "add-btn" to padStyleMapOf(utsMapOf("marginLeft" to 10, "width" to 20, "height" to 20, "lineHeight" to "18px", "fontSize" to 18, "color" to "#ffffff", "backgroundColor" to "#0080b3", "borderTopLeftRadius" to 10, "borderTopRightRadius" to 10, "borderBottomRightRadius" to 10, "borderBottomLeftRadius" to 10, "borderTopWidth" to "medium", "borderRightWidth" to "medium", "borderBottomWidth" to "medium", "borderLeftWidth" to "medium", "borderTopStyle" to "none", "borderRightStyle" to "none", "borderBottomStyle" to "none", "borderLeftStyle" to "none", "borderTopColor" to "#000000", "borderRightColor" to "#000000", "borderBottomColor" to "#000000", "borderLeftColor" to "#000000", "textAlign" to "center", "paddingTop" to 0, "paddingRight" to 0, "paddingBottom" to 0, "paddingLeft" to 0, "backgroundColor:active" to "#0056b3")), "button-group" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "row", "alignItems" to "center", "justifyContent" to "flex-end", "backgroundColor" to "#f0f0f0", "borderTopLeftRadius" to 15, "borderTopRightRadius" to 15, "borderBottomRightRadius" to 15, "borderBottomLeftRadius" to 15, "overflow" to "hidden", "borderTopWidth" to 1, "borderRightWidth" to 1, "borderBottomWidth" to 1, "borderLeftWidth" to 1, "borderTopStyle" to "solid", "borderRightStyle" to "solid", "borderBottomStyle" to "solid", "borderLeftStyle" to "solid", "borderTopColor" to "#e0e0e0", "borderRightColor" to "#e0e0e0", "borderBottomColor" to "#e0e0e0", "borderLeftColor" to "#e0e0e0")), "filter-btn" to utsMapOf("" to utsMapOf("marginLeft" to 0, "paddingTop" to 0, "paddingRight" to 10, "paddingBottom" to 0, "paddingLeft" to 10, "height" to 30, "lineHeight" to "30px", "fontSize" to 12, "color" to "#333333", "backgroundColor" to "#e0e0e0", "borderTopLeftRadius" to 0, "borderTopRightRadius" to 0, "borderBottomRightRadius" to 0, "borderBottomLeftRadius" to 0, "borderTopWidth" to "medium", "borderRightWidth" to 1, "borderBottomWidth" to "medium", "borderLeftWidth" to "medium", "borderTopStyle" to "none", "borderRightStyle" to "solid", "borderBottomStyle" to "none", "borderLeftStyle" to "none", "borderTopColor" to "#000000", "borderRightColor" to "#e0e0e0", "borderBottomColor" to "#000000", "borderLeftColor" to "#000000", "borderRightWidth:last-child" to "medium", "borderRightStyle:last-child" to "none", "borderRightColor:last-child" to "#000000"), ".active" to utsMapOf("!backgroundColor" to "rgba(0,0,0,0)", "!color" to "#007AFF")), "view-all" to padStyleMapOf(utsMapOf("fontSize" to 14, "color" to "#007AFF")), "recent-scroll" to padStyleMapOf(utsMapOf("width" to "100%", "flex" to 1, "display" to "flex", "flexDirection" to "column")), "recent-list" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "column", "paddingTop" to 5, "paddingRight" to 0, "paddingBottom" to 5, "paddingLeft" to 0, "justifyContent" to "flex-start")), "recent-card" to padStyleMapOf(utsMapOf("display" to "flex", "flexDirection" to "column", "paddingTop" to 5, "paddingRight" to 0, "paddingBottom" to 5, "paddingLeft" to 0, "justifyContent" to "flex-start")), "recent-card-head" to padStyleMapOf(utsMapOf("display" to "flex", "paddingTop" to 5, "paddingRight" to 0, "paddingBottom" to 5, "paddingLeft" to 0, "justifyContent" to "flex-start", "borderBottomWidth" to 1, "borderBottomStyle" to "solid", "borderBottomColor" to "#d0d0d0", "marginBottom" to 5)), "recent-body" to padStyleMapOf(utsMapOf("display" to "flex", "flexWrap" to "wrap", "flexDirection" to "row", "width" to "100%", "paddingTop" to 5, "paddingRight" to 0, "paddingBottom" to 5, "paddingLeft" to 0)), "recent-item" to padStyleMapOf(utsMapOf("display" to "flex", "alignItems" to "center", "width" to "32%", "marginRight" to "1%", "marginBottom" to "1%")), "recent-image" to padStyleMapOf(utsMapOf("width" to 100, "height" to 100, "borderTopLeftRadius" to 10, "borderTopRightRadius" to 10, "borderBottomRightRadius" to 10, "borderBottomLeftRadius" to 10, "marginBottom" to 5)), "recent-time" to padStyleMapOf(utsMapOf("fontSize" to 12, "color" to "#666666")), "empty-state" to padStyleMapOf(utsMapOf("flex" to 1, "display" to "flex", "flexDirection" to "column", "justifyContent" to "center", "alignItems" to "center")), "empty-text" to padStyleMapOf(utsMapOf("fontSize" to 16, "color" to "#999999", "marginBottom" to 20, "textAlign" to "center")), "start-btn" to padStyleMapOf(utsMapOf("width" to 200, "height" to 45, "backgroundColor" to "#007AFF", "color" to "#ffffff", "borderTopLeftRadius" to 22.5, "borderTopRightRadius" to 22.5, "borderBottomRightRadius" to 22.5, "borderBottomLeftRadius" to 22.5, "fontSize" to 16)), "footer" to padStyleMapOf(utsMapOf("marginTop" to 20, "textAlign" to "center", "flexShrink" to 0)), "footer-text" to padStyleMapOf(utsMapOf("fontSize" to 12, "color" to "#999999")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = utsMapOf()
        var emits: Map<String, Any?> = utsMapOf()
        var props = normalizePropsOptions(utsMapOf())
        var propsNeedCastKeys: UTSArray<String> = utsArrayOf()
        var components: Map<String, CreateVueComponent> = utsMapOf()
    }
}
